package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import com.google.gson.Gson;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;
import java.util.Map;

/**
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(68)
public class MaoxiandaoGameStrategy extends BaseGameStrategy {

    public static final String URL = "http://106.55.171.140:5003/auto";

    @GongnengMethod(6801)
    public String pay(SendItem item) {
        Map<String,Object> params = new HashMap<>();

        params.put("name", item.uid);
        params.put("num", item.number);
        params.put("type", item.itemId);
        String s = RestTemplateUtil.sendPostJsonAndGetJsonKey(URL, params, "msg");
        return s.contains("完成") ? "发送成功" : "发送失败，截图联系客服";
    }
    @GongnengMethod(6802)
    public String mail(SendItem item) {
        Map<String,Object> params = new HashMap<>();

        params.put("name", item.uid);
        params.put("num", item.number);
        params.put("type", 5);
        params.put("itemId", item.itemId);


        String s = RestTemplateUtil.sendPostJsonAndGetJsonKey(URL, params, "msg");
        return s.contains("完成") ? "发送成功" : "发送失败，截图联系客服";
    }



    @GongnengMethod(9)
    public String clear(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }

    public static void main(String[] args) {
        SendItem item = new SendItem();
        item.uid = "发啊";
        item.number = "1";
        item.itemId = "5010000";
        System.out.println(new MaoxiandaoGameStrategy().mail(item));
    }
}

